package com.hzhr.iot.cqgas.ds.controller;

import com.hzhr.iot.cqgas.ds.dao.user.example.UsrDeptDao;
import com.hzhr.iot.cqgas.ds.entity.user.UsrDeptEntity;
import com.hzhr.iot.cqgas.ds.entity.user.UsrDeptExample;
import com.hzhr.iot.cqgas.ds.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DeptController {
    @Autowired
    DeptService deptService;
    @Autowired
    UsrDeptDao usrDeptDao;

    @RequestMapping(value = "/syncDept")
    public void syncIotCompany() {
        UsrDeptEntity usrDeptEntity = new UsrDeptEntity();
        usrDeptEntity.setState("3");
        UsrDeptExample usrDeptExample = new UsrDeptExample();
        usrDeptExample.createCriteria().andOutIdIsNotNull();
        usrDeptDao.updateByExampleSelective(usrDeptEntity, usrDeptExample);

        deptService.syncDept();

        usrDeptExample = new UsrDeptExample();
        usrDeptExample.createCriteria().andStateEqualTo("3");
        usrDeptDao.deleteByExample(usrDeptExample);
    }
}
